package com.zxmc.server.mapper;

import com.zxmc.pojo.entity.ReadingHistory;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ReadingHistoryMapper {
    @Select("select * from readinghistory where user_id=#{userId} and novel_id=#{novelId};")
    ReadingHistory list(@Param("novelId") Integer novelId, @Param("userId") Integer userId);

    @Insert("insert into readinghistory (user_id, novel_id, last_read_title, read_time, last_read_time, last_read) values" +
            "(#{userId}, #{novelId}, #{lastReadTitle}, #{readTime}, #{lastReadTime}, #{lastRead})")
    void insert(ReadingHistory readingHistory);

    void update(ReadingHistory readingHistory);
    @Select("select * from readinghistory where user_id=#{userId}")
    List<ReadingHistory> listAll(Integer userId);
}
